"""
 encoding    : utf-8
 @File       : zonghechaxun.py
 @Author     : qin
 @Version    :
 @Description:
 @Date       : 2024/06/22
"""
import time

from common.logincommon import LoginCommon
from common.commonfunctions import Common
from selenium.webdriver.support.select import Select


class ZongHeChaXun(LoginCommon):
    def oprate_web(self):
        # 定位综合查询按钮并并点击
        Common.getElement(self.driver, 'xpath', '/html/body/div[2]/div/div[1]/table/tbody/tr[17]/td/a/img').click()
        # 切换到第一层frame
        frame_ele = Common.getElement(self.driver, 'id', 'iframe_main')
        self.driver.switch_to.frame(frame_ele)
        #切换到第二层frame
        frame_ele = Common.getElement(self.driver, 'xpath', '/html/frameset/frame[1]')
        self.driver.switch_to.frame(frame_ele)
        #定位筛选下拉框按钮
        select_ele1 = Common.getElement(self.driver, 'xpath', '/html/body/form/div[1]/div[3]/div[1]/select')
        #定义一个选择对象
        select_obj1 = Select(select_ele1)
        #选择已办下拉框
        select_obj1.select_by_visible_text('已办')
        #定位第二个下拉框元素
        select_ele2 = Common.getElement(self.driver, 'xpath', '/html/body/form/div[1]/div[3]/div[2]/select')
        #定义下拉框对象2
        select_obj2 = Select(select_ele2)
        #选择已归档下拉框
        select_obj2.select_by_value('archive')
        #定位查询按钮并点击
        Common.getElement(self.driver, 'id', 'searchButton').click()

    def cancel(self):
        self.driver.switch_to.default_content()
        # 切换到第一层frame
        frame_ele = Common.getElement(self.driver, 'id', 'iframe_main')
        self.driver.switch_to.frame(frame_ele)
        # 切换到第二层frame
        frame_ele = Common.getElement(self.driver, 'xpath', '/html/frameset/frame[1]')
        self.driver.switch_to.frame(frame_ele)
        #定位记录并点击
        Common.getElement(self.driver, 'xpath', '/html/body/form/div[2]/div/div[1]/div[2]/table/tbody/tr[1]/td[1]/div/input').click()
        #定位撤销按钮并点击
        Common.getElement(self.driver, 'xpath', '/html/body/form/div[1]/div[1]/button').click()
        #返回到最外层
        self.driver.switch_to.default_content()
        #定位确定按钮并点击
        Common.getElement(self.driver, 'xpath', '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[3]/td/div/input[1]').click()

    def check_cancel(self,content):
        self.driver.switch_to.default_content()
        #定位元素的文本内容
        text = Common.getElement(self.driver, 'xpath', '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]').text
        #定位确定按钮并点击
        Common.getElement(self.driver, 'xpath', '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[3]/td/div/input').click()
        assert text == content,'测试失败!'

    def back(self):
        pass